<!DOCTYPE HTML>
<html>
<!--_meta 作为公共模版分离出去-->
{include file="common/_meta"}
<!--/meta 作为公共模版分离出去-->

<body>
<!--_header 作为公共模版分离出去-->
{include file="common/_header"}
<!--/_header 作为公共模版分离出去-->
<!--_menu 作为公共模版分离出去-->
{include file="common/_menu"}
<!--/_menu 作为公共模版分离出去-->

<section class="Hui-article-box">
    <!--_nav 作为公共模版分离出去-->
{include file="common/_nav"}
<!--/_nav 作为公共模版分离出去-->
<article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="form-admin-pwd">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>原密码：</label>
            <div class="formControls col-xs-8 col-sm-2">
                <input type="password" class="input-text" autocomplete="off" value="" placeholder="初始密码" id="oldpassword" name="oldpassword">
            </div>
            <span class="oldspan c-red"></span>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>新密码：</label>
            <div class="formControls col-xs-4 col-sm-2">
                <input type="password" class="input-text" autocomplete="off" value="" placeholder="请输入新密码" id="newpassword" name="newpassword">
            </div>
            <span class="newspan col-xs-4 col-sm-4 c-red"></span>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-xs-8 col-sm-2">
                <input type="password" class="input-text" autocomplete="off" value="" placeholder="请再次输入新密码" id="repassword" name="repassword">
            </div>
            <span class="respan  c-red"></span>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-1">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                <input class="btn btn-default radius" type="button" value="&nbsp;&nbsp;取消&nbsp;&nbsp;" onClick="window.history.back();">
            </div>
        </div>
    </form>
</article>
</div>
</section>
<!--_footer 作为公共模版分离出去-->
{include file="common/_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">
    var test=true; 
//检查input是否为空
    function checkEmpty(data,holder,msg){
        if(data.length <= 0){
            $(holder).html(msg);
            return false;
        }else{
            $(holder).html('');
            return true; 
        }
    }   
//验证原密码
    function checkOldpassword(){
        var oldpassword=$("#oldpassword").val();
        test=checkEmpty(oldpassword,'.pspan','原密码不能为空');
        if(!test) return false;
        $test=$.post('modifypwd',{'password':oldpassword},function(data){
            if(data.status!=1){
                // alert(test);
                $('.oldspan').html("* 原密码不正确请重新输入");
                return false;
            }else{
                $('.oldspan').html("");
                return true;
            }
        },'json');
        return test;
    }
    $("#oldpassword").change(function(){
        test=checkOldpassword();
    });
//验证二次输入密码
    function checkNewpassword(){
        var newpassword=$("#newpassword").val();
        test=checkEmpty(newpassword,'.pspan','密码不能为空');
        if(!test) return false;
        test=newpassword.match(/^[a-zA-Z]\w{5,17}$/); 
        if(!test){
            $('.newspan').html("* 新密码必须字母开头，长度在6-18之间，只能包含字符、数字和下划线");
        }else{
            $('.newspan').html("");
            return true;
        }
    }
    $("#newpassword").blur(function(){
        test=checkNewpassword();
    });
    function checkRepassword(){
        var newpassword=$("#newpassword").val();
        var repassword=$("#repassword").val();
        if(newpassword!=repassword){
            $('.respan').html("* 两次密码不一致,请重新输入");
            return false;
        }else{
            $('.respan').html("");
            return true;
        }
    }
    $("#repassword").blur(function(){
        test=checkNewpassword();
        if(!test) return false;
        test=checkRepassword(); 
    });
    $("#form-admin-pwd").submit(function(){
        if(!test) return false;
        test=checkOldpassword();
        if(!test) return false;
        test=checkNewpassword();
        if(!test) return false;
    })
</script>
<!--请在上方写此页面业务相关的脚本--> 
</body>
</html>